<template>
	<view class="container">
		<view class="container-info">
			<view class="container-info-box">
				入睡时间：
				<span>{{form.sleepTime}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				苏醒时间：
				<span>{{form.wakeupTime}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				睡眠质量：

					<u-rate v-model="form.rankVal" size="40" active-color="#f3bb2e"></u-rate>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box" style="display: flex;">
				<view class="remark-lable">备注：</view>
				<textarea  v-model="form.remark" rows="3" placeholder="请输入备注"/>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getRecordSleepInfo
	} from './api/index.js'
	import recordMixin from './mixins/info.js'
	import LmageListView from '@/components/image-list-view.vue'
	import {
		formatDateByTimestamp
	} from '@/utils/utils.js'
	export default {
		mixins: [recordMixin],
		components: {
			LmageListView
		},
		data() {
			return {
				form: {
					eventTime: formatDateByTimestamp(Date.now(), 'yyyy/mm/dd hh:MM:ss'),
					temperature: 36.5,
					emotion: 3,
					bodyState: 3,
					remark: '',
				},
				radioList: [{
						name: '安稳',
					},
					{
						name: '普通',
					},
					{
						name: '不安稳'
					},
					{
						name: '易惊醒'
					}
				],
			}
		},
		filters: {
			resourceUrlFilter (value) {
				if (!value) {
					return []
				}
				return value.split('|');
			}
		},
		methods: {
			getValue(list,value) {
				return list.find(item => item.value * 1 === value * 1)?.name
			},
			getRecord() {
				console.log(this.recordId)
				if (this.$u.test.isEmpty(this.recordId)) {
					return;
				}
				uni.showLoading({})
				const params = {
					id: this.recordId,
					childId: this.defaultChildren.id
				}
				getRecordSleepInfo(params).then(res => {
					uni.hideLoading()
					const { rankVal, remark } = res.data; 
					const eventTime = formatDateByTimestamp(res.data.eventTime, 'yyyy/mm/dd hh:MM:ss')
					const sleepTime = formatDateByTimestamp(res.data.sleepTime, 'yyyy/mm/dd hh:MM:ss')
					const wakeupTime = formatDateByTimestamp(res.data.wakeupTime, 'yyyy/mm/dd hh:MM:ss')
					const form = {
						eventTime,
						sleepTime,
						wakeupTime,
						rankVal,
						remark,
					};
					this.form = form
				})

			
			},
		}
	}
</script>

<style lang="scss" scoped>


</style>
